
package utils;

import daos.TimeDAO;
import entitys.Time;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

@FacesConverter(value = "converterTime", forClass = Time.class)
public class ConverterTime implements Converter {

    private TimeDAO dao = new TimeDAO();
    
    @Override
    public Object getAsObject(FacesContext fc, UIComponent uic, String string) {
        return dao.findById(Long.parseLong(string));
    }

    @Override
    public String getAsString(FacesContext fc, UIComponent uic, Object o) {
        return String.valueOf(((Time)o).getId());
    }
    
}